package com.linkage.jz.bankruptcy.bean;

import android.text.TextUtils;

import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;

import java.util.ArrayList;
import java.util.List;

/**
 * @author AFAP
 * 讨论回复
 */
public class ProTalkReply {

    /**
     * id : 1
     * subjectId : 3671d47759b64527aebf051dc5bc8c2f
     * creditorId : df76aa8f68cf4b629e46a3beaaa257c9
     * replyContent : heiheihei
     * opAt : 1551945057
     * delFlag : false
     */

    private String id;
    private String subjectId;
    private String creditorId;
    private String replyContent;
    private long opAt;
    private boolean delFlag;
    private UserInfo user;

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getSubjectId() {
        return subjectId;
    }

    public void setSubjectId(String subjectId) {
        this.subjectId = subjectId;
    }

    public String getCreditorId() {
        return creditorId;
    }

    public void setCreditorId(String creditorId) {
        this.creditorId = creditorId;
    }

    public String getReplyContent() {
        return replyContent;
    }

    public void setReplyContent(String replyContent) {
        this.replyContent = replyContent;
    }

    public long getOpAt() {
        return opAt;
    }

    public void setOpAt(long opAt) {
        this.opAt = opAt;
    }

    public boolean isDelFlag() {
        return delFlag;
    }

    public void setDelFlag(boolean delFlag) {
        this.delFlag = delFlag;
    }

    public UserInfo getUser() {
        return user;
    }

    public void setUser(UserInfo user) {
        this.user = user;
    }

    public ProTalkReplyAuth auth;

    public static List<ProTalkReply> parse(JsonArray arr) {
        List<ProTalkReply> list = new ArrayList<>();
        for (int i = 0; i < arr.size(); i++) {
            list.add(parse(arr.get(i).getAsJsonObject()));
        }
        return list;
    }

    public static ProTalkReply parse(JsonObject obj) {
        ProTalkReply bean = new Gson().fromJson(obj, ProTalkReply.class);
        if (TextUtils.isEmpty(bean.getUser().getAvatar())) {
            bean.getUser().setAvatar("NA");
        }
        return bean;
    }
}
